#正则断言
#找位置
#位置在右边的(?=) (?!)
#位置在左边的(?<=) (?<!)
import re
# s="a regular rbgular expression"
# print(re.findall(r"\w+(?=gular)",s))
# print(re.findall(r"re(?!gular)",s))
# print(re.findall(r"(?<=re)gular",s))
# print(re.findall(r"(?<!re)gular",s))

# msg = "i am cici,welcom to 'sc t1' ths"
# print(re.findall(r"\w+",msg))
# print(re.findall(r"(?<=').+(?=')|\w+",msg))
#

import requests
import sys
import io
# <img src="/upload/infomation/%E5%9B%BD%E5%8A%A1%E9%99%A2-%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD_9h00aCg.jpg" alt="">
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')
result = requests.get("https://www.sanchuangedu.cn")
ret=re.findall(r"(?:<img\s.*=\")(.*\.jpg)",result.text)
print(ret)
n=0
for i in ret:
    n += 1
    r = "https://www.sanchuangedu.cn"+i
    t = requests.get(r)
    y = t .content
    dir_name=f"img/sanchuangImage{n}.jpg"
    with open(dir_name,'wb')as f:
        f.write(y)
